// import Vue from 'vue';

// const eventBus = new Vue({});
// export default eventBus;

// 自定义eventBus事件
// 使用单例模式

// class EventBus {

// }
const subscribes = {}

const eventBus = {
	$emit: (type, value) => {
		if (subscribes[type]) {
			subscribes[type].forEach(fn => {
				fn(value)
			})
		}
	},
	$on: (type, callback) => {
		if (!subscribes[type]) {
			subscribes[type] = []
		}
		subscribes[type].push(callback);
	}
}


export default eventBus;